var wxTitle = "最美教师节，只因遇见你";
var wxDesc = "一键生成我的教师节专属海报";
var wxLink = document.location.href;
var wxImgUrl = "http://www.xyzit.cn/rise/resource/share.jpg";

var appid, timestamp, noncestr, signature;

$.ajax({
	type: "POST",
	url: "http://9sd6qf.natappfree.cc/teacher/api/getweiconfig",
	data: {},
	dataType: "json",
	success: function(data) {
		console.log(data)
		appid = data.appId;
		noncestr = data.nonceStr;
		timestamp = data.timestamp;
		signature = data.signature;

		wx.config({
			debug: true,
			appId: appid,
			timestamp: timestamp,
			nonceStr: noncestr,
			signature: signature,
			jsApiList: [
				"onMenuShareTimeline",
				"onMenuShareAppMessage",
				"onMenuShareQQ",
				"onMenuShareWeibo"
			]
		});

		wx.error(function(res) {
			//console.log(res)
		});

		wx.ready(function() {
			wx.onMenuShareTimeline({
				title: wxDesc,
				link: wxLink,
				imgUrl: wxImgUrl
			});
			wx.onMenuShareQQ({
				title: wxTitle,
				desc: wxDesc,
				link: wxLink,
				imgUrl: wxImgUrl
			});
			wx.onMenuShareWeibo({
				title: wxTitle,
				desc: wxDesc,
				link: wxLink,
				imgUrl: wxImgUrl
			});
			wx.onMenuShareAppMessage({
				title: wxTitle,
				desc: wxDesc,
				link: wxLink,
				imgUrl: wxImgUrl,
				type: 'link',
				dataUrl: ''
			});
		});
	}
});